package com.apes.scm.masterdata.stock.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = DcDistributionRange.CONST_TABLE_NAME)
public class DcDistributionRange extends Model {
    public static final String CONST_TABLE_NAME = "mas_dc_distribution_range";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, padding = 1, name = "DC配送范围编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "F_location_id", referencedColumnName = "id")
    @Comment("父仓库")
    private Location FLocationId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "C_location_id", referencedColumnName = "id")
    @Comment("子仓库")
    private Location CLocationId;

    @Column(name = "online_weights", columnDefinition = "number(8) default 0")
    @Comment("线上要货配货权重")
    private int onlineWeights = 0;

    @Column(name = "offline_weights", columnDefinition = "number(8) default 0")
    @Comment("线下要货配货权重")
    private int offlineWeights = 0;

    @Column(name = "safety_stock_mark", columnDefinition = "number(8) default 0")
    @Comment("安全库存配货标记")
    private int safetyStockMark = 0;

}
